package com.wangwei.sort;

public class MergeBU extends Merge{

    @Override
    public void sort(Comparable[] arr) {
        int n = arr.length;
        Comparable[] aux = new Comparable[n];
        for (int len = 1; len < n; len *= 2) {
            for (int lo = 0; lo < n-len; lo += len+len) {
                //todo wangwei 此处没看懂
                int mid  = lo+len-1;
                int hi = Math.min(lo+len+len-1, n-1);
                merge(arr, aux, lo, mid, hi);
            }
        }
        assert isSorted(arr);
    }
}
